﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StudentEx
{
    public class Student : ICloneable, IComparable<Student>
    {
        private string firstName;
        private string lastName;
        private string sirName;
        private string address;
        private string phone;
        private string mail;
        private int course;
        private Specialties specialty;
        private Universities university;
        private Faculties faculty;
        private string ssn;

        public string FirstName
        {
            get
            {
                return firstName;
            }
            set
            {
                firstName = value;
            }
        }

        public string LastName
        {
            get
            {
                return lastName;
            }
            set
            {
                lastName = value;
            }
        }

        public string SirName
        {
            get
            {
                return sirName;
            }
            set
            {
                sirName = value;
            }
        }

        public string Address
        {
            get
            {
                return address;
            }
            set
            {
                address = value;
            }
        }

        public string Phone
        {
            get
            {
                return phone;
            }
            set
            {
                phone = value;
            }
        }

        public string Mail
        {
            get
            {
                return mail;
            }
            set
            {
                mail = value;
            }
        }

        public int Course
        {
            get
            {
                return course;
            }
            set
            {
                course = value;
            }
        }

        public Specialties Specialty
        {
            get
            {
                return specialty;
            }
            set
            {
                specialty = value;
            }
        }

        public Universities University
        {
            get
            {
                return university;
            }
            set
            {
                university = value;
            }
        }

        public Faculties Faculty
        {
            get
            {
                return faculty;
            }
            set
            {
                faculty = value;
            }
        }

        public string Ssn
        {
            get
            {
                return ssn;
            }
            set
            {
                ssn = value;
            }
        }

        public Student(string firstName, string lastName, string sirName, string address, string phone, string mail, int course, Specialties specialty, Universities university, Faculties faculty, string ssn)
        {
            this.firstName = firstName;
            this.lastName = lastName;
            this.sirName = sirName;
            this.address = address;
            this.phone = phone;
            this.mail = mail;
            this.course = course;
            this.specialty = specialty;
            this.university = university;
            this.faculty = faculty;
            this.ssn = ssn;
        }

        public override int GetHashCode()
        {
            return firstName.GetHashCode() ^ lastName.GetHashCode() ^ sirName.GetHashCode()
                   ^ address.GetHashCode() ^ phone.GetHashCode() ^ mail.GetHashCode() ^ course.GetHashCode()
                   ^ specialty.GetHashCode() ^ university.GetHashCode() ^ faculty.GetHashCode() ^ ssn.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            Student other = obj as Student;
            if (Object.ReferenceEquals(other, null))
            {
                return false;
            }
            return this.ssn == other.ssn;
        }

        public static bool operator ==(Student first, Student second)
        {
            if (ReferenceEquals(first, null) && ReferenceEquals(second, null))
            {
                return true;
            }

            if (ReferenceEquals(first, null) || ReferenceEquals(second, null))
            {
                return false;
            }

            return first.Equals(second);
        }

        public static bool operator !=(Student first, Student second)
        {
            return !(first == second);
        }

        object ICloneable.Clone()
        {
            return MemberwiseClone();
        }

        public Student Clone()
        {
            return (Student)MemberwiseClone();
        }

        public int CompareTo(Student other)
        {
            if (this.firstName != other.firstName)
            {
                return this.firstName.CompareTo(other.firstName);
            }

            if (this.lastName != other.lastName)
            {
                return this.lastName.CompareTo(other.lastName);
            }

            if (this.sirName != other.sirName)
            {
                return this.sirName.CompareTo(other.sirName);
            }

            return this.ssn.CompareTo(other.ssn);
        }
    }
}
